package com.saret.dictionary;

import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.saret.crawler.search.BingWebSearch;
import com.saret.crawler.search.WebTranslate;
import com.saret.utils.BindUtil;
import com.saret.utils.FileLocator;

import java.io.IOException;

/**
 * User: biniam.gebremichael
 * Date: 2/3/11
 */
public class LoadDictionary {

    private static final Module[] modules = {
            new Module() {
                @Override
                public void configure(Binder binder) {
                    BindUtil.bindProperties(binder, FileLocator.getConfigFile("project.properties"));
                    binder.bind(WebTranslate.class).to(BingWebSearch.class);
                    binder.bind(Dictionary.class).asEagerSingleton();
                }
            }
    };

    public static void main(String[] args) throws IOException {
        Injector injector = Guice.createInjector(modules);
        Dictionary dictionary = injector.getInstance(Dictionary.class);
        if (args.length >= 1) {
            for (String arg : args) {
                dictionary.getResult(arg.replaceAll("\"", ""));
            }
        } else {
            System.out.println("Usage: saret ENGLISH_WORD1 ENGLISH_WORD2 ... \nexample:\n\tsaret adaptation training");
        }
    }
}
